#pragma once
#include<vector>
#include<string>
#include<list>
#include<unordered_map>
#include<vector>
#include<sstream>
#include<fstream>
#include<list>
#include<iostream>

using std::string;
using std::vector;
using std::make_pair;
using std::pair;
using std::unordered_map;
using std::list;
using std::cout;
using std::endl;


class LRUCache
{
public:
    LRUCache( int capacity )
    : _capacity(capacity){
        _pendingcapacity = capacity/4;
    }

    int get(std::string query,std::pair<std::string,std::vector<std::string>> &res);

    int put(std::string query,std::vector<std::string> recommand);

    int writeToFile();

    int readToFile();

    int clearpending();

public:
    std::list<std::pair<std::string,std::vector<std::string>>> _dlist;
    std::list<std::pair<std::string,std::vector<std::string>>> _pendingUpdateList;
    std::unordered_map<std::string, std::list<std::pair<std::string,std::vector<std::string>>>::iterator> _pendingHash;
    std::unordered_map<std::string, std::list<std::pair<std::string,std::vector<std::string>>>::iterator> _cache;
    int _capacity;
    int _pendingcapacity;
};
